package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportRecordAcceptDto;
import com.yqg.protection.entity.RecordAccept;
import com.yqg.protection.mapper.RecordAcceptMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/14 18:01
 * description:
 */
@Component
public class RecordAcceptListener extends AnalysisEventListener<ImportRecordAcceptDto> {

    @Autowired
    private RecordAcceptMapper recordAcceptMapper;

    @Override
    public void invoke(ImportRecordAcceptDto importRecordAcceptDto, AnalysisContext analysisContext) {
        RecordAccept recordAccept = new RecordAccept();
        BeanUtil.copyProperties(importRecordAcceptDto, recordAccept, true);
        recordAccept.setIsDelete(0);
        recordAcceptMapper.insert(recordAccept);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
